<template>
  <div class="centers diolog_adapt">
    <el-form :model="addForm" ref="deliveryForm">
      <el-form-item label="用户名称:" label-width="140px">
        <el-input v-model="addForm.username" autocomplete="off"></el-input>
      </el-form-item>
      <!-- <div class="flex flex_bet">
        <el-form-item label="型号选择:" label-width="140px" prop="thereId" class="boxitem">
          <el-select v-model="addForm.thereId" placeholder="没有选中任何项" style="width:100%"></el-select>
        </el-form-item>
        <el-form-item label="型号选择:" label-width="140px" prop="thereId" class="boxitem">
          <el-select v-model="addForm.thereId" placeholder="没有选中任何项" style="width:100%"></el-select>
        </el-form-item>
      </div> -->
      <div class="flex flex_bet">
        <el-form-item label="需求类型:" label-width="140px" prop="demand_type" class="boxitem">
          <el-select v-model="addForm.r_demand_type" placeholder="没有选中任何项" style="width:100%"></el-select>
        </el-form-item>
        <el-form-item label="审核需求类型:" label-width="140px" prop="demand_type" class="boxitem">
          <el-select v-model="addForm.f_demand_type" placeholder="没有选中任何项" style="width:100%"></el-select>
        </el-form-item>
      </div>
      <div class="flex flex_bet">
        <el-form-item label="期望完成日期:" label-width="140px" prop="expect_time" class="boxitem">
          <el-date-picker v-model="addForm.expect_time" type="date" placeholder="选择日期" :picker-options="pickerOptions0" format="yyyy 年 MM 月 dd 日" value-format="timestamp">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划完成日期:" label-width="140px" prop="plan_time" class="boxitem">
          <el-date-picker v-model="addForm.plan_time" type="date" placeholder="选择日期" :picker-options="pickerOptions0" format="yyyy 年 MM 月 dd 日" value-format="timestamp"></el-date-picker>
        </el-form-item>
      </div>
      <div v-for="(item,index) in addForm.deliver" :key="index">
        <el-form-item :label="`匹配硬件版本${index + 1}`" label-width="140px">
          <el-input v-model="item.name_code" autocomplete="off" :placeholder="`请输入匹配硬件版本${index + 1}`"></el-input>
        </el-form-item>
        <el-form-item label="固件版本信息" label-width="140px">
          <el-input v-model="item.firmware_version" autocomplete="off" placeholder="请输入固件版本信息"></el-input>
        </el-form-item>
        <el-form-item label="固件下载信息" label-width="140px">
          <el-input v-model="item.firmware_address" autocomplete="off" placeholder="固件下载信息"></el-input>
        </el-form-item>
        <el-form-item label="固件简单描述" label-width="140px">
          <el-input v-model="item.remark" autocomplete="off" placeholder="固件简单描述"></el-input>
        </el-form-item>
        <div class="flex flex_bet">
          <el-form-item label="实际交付日期" label-width="140px" class="boxitem">
            <el-date-picker v-model="item.actual_time" type="date" placeholder="选择日期" :picker-options="pickerOptions0" format="yyyy 年 MM 月 dd 日" value-format="timestamp" @change="deliveryDate($event,index)">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="完成耗时" label-width="140px" class="boxitem">
            <el-input v-model="item.take_time" autocomplete="off" placeholder="完成耗时"></el-input>
          </el-form-item>
        </div>
      </div>
      <div class="flex flex_bet">
        <div style="width:49%">
          <el-form-item label="开机LOGO:" label-width="140px">
            <el-input v-model="addForm.r_start_logo" autocomplete="off" placeholder="请上传开机logo图"></el-input>
          </el-form-item>
          <el-form-item label="开机动画:" label-width="140px">
            <el-input v-model="addForm.r_start_animation" autocomplete="off" placeholder="请上传开机动画"></el-input>
          </el-form-item>
          <el-form-item label="开机铃声:" label-width="140px">
            <el-input v-model="addForm.r_start_ring" autocomplete="off" placeholder="请输入开机铃声格式"></el-input>
          </el-form-item>
          <el-form-item label="默认壁纸:" label-width="140px">
            <el-input v-model="addForm.r_wallpaper" autocomplete="off" placeholder="请上传默认壁纸"></el-input>
          </el-form-item>
          <el-form-item label="应用内置需求:" label-width="140px">
            <el-input v-model="addForm.r_app_demand" autocomplete="off" placeholder="请输入应用内置需求"></el-input>
          </el-form-item>
          <el-form-item label="Launcher桌面需求:" label-width="140px">
            <el-input v-model="addForm.r_launcher_desktop" autocomplete="off" placeholder="请输入Launcher桌面需求"></el-input>
          </el-form-item>
          <el-form-item label="系统语言需求:" label-width="140px">
            <el-input v-model="addForm.r_language" autocomplete="off" placeholder="请输入系统语言需求"></el-input>
          </el-form-item>
          <el-form-item label="系统输入法需求:" label-width="140px">
            <el-input v-model="addForm.r_type_writing" autocomplete="off" placeholder="请输入系统输入法需求"></el-input>
          </el-form-item>
          <el-form-item label="OTA升级需求:" label-width="140px">
            <el-input v-model="addForm.r_ota_demand" autocomplete="off" placeholder="请输入OTA升级需求"></el-input>
          </el-form-item>
          <el-form-item label="其他需求补充:" label-width="140px">
            <el-input v-model="addForm.r_other_demand" autocomplete="off" placeholder="其他需求补充或直接导入xlsx表格" style="flex:1">
              <el-button slot="append" icon="el-icon-download" @click="xlsxDownload(addForm.r_other_demand)" style="font-size: 14px"></el-button>
            </el-input>
          </el-form-item>
        </div>
        <div style="width:49%">
          <el-form-item label="审核意见:" label-width="140px" prop="start_logo">
            <el-input v-model="addForm.f_start_logo" autocomplete="off" placeholder="请上传开机logo图"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="start_animation">
            <el-input v-model="addForm.f_start_animation" autocomplete="off" placeholder="请上传开机动画"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="start_ring">
            <el-input v-model="addForm.f_start_ring" autocomplete="off" placeholder="请输入开机铃声格式"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="wallpaper">
            <el-input v-model="addForm.f_wallpaper" autocomplete="off" placeholder="请上传默认壁纸"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="app_demand">
            <el-input v-model="addForm.f_app_demand" autocomplete="off" placeholder="请输入应用内置需求"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="launcher_desktop">
            <el-input v-model="addForm.f_launcher_desktop" autocomplete="off" placeholder="请输入Launcher桌面需求"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="language">
            <el-input v-model="addForm.f_language" autocomplete="off" placeholder="请输入系统语言需求"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="type_writing">
            <el-input v-model="addForm.f_type_writing" autocomplete="off" placeholder="请输入系统输入法需求"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="ota_demand">
            <el-input v-model="addForm.f_ota_demand" autocomplete="off" placeholder="请输入OTA升级需求"></el-input>
          </el-form-item>
          <el-form-item label="审核意见:" label-width="140px" prop="other_demand">
            <el-input v-model="addForm.f_other_demand" autocomplete="off" placeholder="其他需求补充或直接导入xlsx表格" style="flex:1"></el-input>
          </el-form-item>
        </div>
      </div>
    </el-form>
  </div>
</template>

<script>
import { queryIdFirmwareDeliver } from "@/api/firmware.js";
export default {
  props: {
    checkId: {
      type: Number,
      default() {
        return 1
      }
    }
  },
  data() {
    return {
      addForm: {},
      //限制日期选择框范围
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
    }
  },
  created() {
    this.getqueryIdFirmwareDeliver(this.checkId)
  },
  methods: {
    getqueryIdFirmwareDeliver(id) {
      queryIdFirmwareDeliver({ id: id }).then(res => {
        this.addForm = res.data
        this.addForm.expect_time = res.data.expect_time * 1000
        this.addForm.plan_time = res.data.plan_time * 1000
        this.addForm.deliver.forEach(item => {
          item.actual_time ? item.actual_time = item.actual_time * 1000 : ''
          item.take_time ? item.take_time = item.take_time.toString() + '天' : ''
        })
        console.log('查看固件信息数据', res.data)
      }).catch(err => {
        this.addForm = []
      })
    },
    xlsxDownload(url) {
      window.open('https://' + url)
    }
  }
}
</script>

<style scoped lang="scss">
.hardwareDate {
  display: flex;
  flex-wrap: wrap;
}
.boxitem {
  width: 49%;
}
</style>

<style scoped>
/deep/ .el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 100%;
}
</style>